<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>员工列表</title>
</head>
<body>
<table id="dataTable">
    <tr>
        <th colspan="6">员工信息(<a th:href="@{/Add}">add</a>)</th>
    </tr>
    <tr bgcolor="aqua">
        <th>id</th>
        <th>name</th>
        <th>age</th>
        <th>gender</th>
        <th>email</th>
        <th>options</th>
    </tr>
    <tr th:each="employee : ${list}">
        <td th:text="${employee.empId}"></td>
        <td th:text="${employee.empName}"></td>
        <td th:text="${employee.age}"></td>
        <td th:text="${employee.gender}"></td>
        <td th:text="${employee.email}"></td>
        <td>
            <a @click="deleteEmployee" th:href="@{'/employee/' + ${employee.empId}}">delete</a>
            <a th:href="@{'/toUpdate/' + ${employee.empId}}">update</a>
        </td>
    </tr>
</table>

<form id="deleteForm" method="post">
    <input type="hidden" name="_method" value="delete"/>
</form>

<script type="text/javascript" th:src="@{/static/js/vue.js}"></script>
<script type="text/javascript">
    var vue = new Vue({
        el:"#dataTable",
        methods:{
            deleteEmployee:function (event) {
                var deleteForm = document.getElementById("deleteForm");
                deleteForm.action = event.target.href;
                deleteForm.submit();
                event.preventDefault();
            }
        }
    });
</script>

</body>
</html>